<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <button>开始</button>
    <button>停止</button>

    <script>
        const btns = document.querySelectorAll("button")
        let setInterval1;
        btns[0].addEventListener("click", function () {
            setInterval1 = setInterval(function () {
                console.log('开始')
            }, 1000)
        })

        btns[1].addEventListener("click", function () {
            clearInterval(setInterval1)
            console.log('停止')
        })
    </script>

</body>

</html>